﻿using System;
using System.Windows.Forms;

namespace WinFormsApp_ImitateMouseAndKeyboard
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //模拟鼠标/键盘:


            //调用:
            Mouse.SetCursorPos(MousePosition.X, MousePosition.Y);//(100, 100);
            Mouse.LeftClick();//左键
            Mouse.RightClick();//右键

            //键盘操作可以用:
            // SendKeys.SendWait();
            //Msn帮助:ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemWindowsFormsSendKeysClassTopic.htm



            //如:
            //关闭显示器可以用:
            //Windows.SendMessage(this.Handle.ToInt32(),0x112,0xF170,2);
            //打开
            //Windows.SendMessage(this.Handle.ToInt32(),0x112,0xF170,-1);

            label1.Text = MousePosition.X + "," + MousePosition.Y;
        }
    }
}
